Create a new function method in your class module called errHandler and enter the code from Listing 14.18.
Listing 14.18. Coding the errHandler function.
Public Function errHandler(objErrColl As Variant, Optional intType As errType, Optional errOption As errReturn, Optional errRefName As String) As errReturn
' --------------------------------------------------------------------------
' produce msg and prompt for response
'
' inputs:
' objErrColl - DAO collection -OR- VBA Err object
' intType - errType enum that describes objErrColl (coll or item)
' errOption - errReturn enum sets dialog behavior (exit, resume, next, select)
' errRefName - string to reference caller
'
' returns:
' errExit - end program
' errResume - try again
' errNext - skip to next line
' --------------------------------------------------------------------------
'
Dim strMsg As String
Dim strTitle As String
Dim rtnValue As errReturn
'
' retrieve action option
If IsMissing(errOption) Then
errOption = errDefRtn
End If
'
' retrieve reference name
If IsMissing(errRefName) Then
errRefName = ""
Else
errRefName = " from " & errRefName
End If
'
' build full message
strMsg = errMsg(objErrColl, intType)
'
' write it out, if allowed
If errLogFlag = True Then
LogError strMsg
End If
'
' evaluate things
Select Case errOption
Case errExit
udtErrDialog.Title = "Exiting Program"
udtErrDialog.Message = strMsg